package Concurrency4_GeekTime.Chapter23_Future;

import java.util.concurrent.*;

/**
 * 功能说明：
 * 开发人员：@author MaLi
 */
public class Base02_FutureTask {
    public static void main(String[] args) {
        FutureTask<String> task = new FutureTask<>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                return "OK";
            }
        });

        ExecutorService pool = Executors.newFixedThreadPool(1);
        Future<String> future = (Future<String>) pool.submit(task);
        try {
            String result = future.get();
            System.out.println(" 1----> "+result);
            result = task.get();
            System.out.println(" 2----> "+result);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }

    }
}
